package dao

import (
	"zk2zc/inits"
	"zk2zc/model"
)

func CreateMessage(formUserId int, toUserId int, context string) bool {
	var min1 = formUserId
	var max1 = toUserId
	if formUserId > toUserId {
		min1 = toUserId
		max1 = formUserId
	}
	data := &model.Message{
		FormUserId: formUserId,
		ToUserId:   toUserId,
		Context:    context,
		RoomId:     min1*100000 + max1,
	}
	if inits.DB.Create(&data).Error != nil {
		return false
	}
	return true
}
